package foti;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class toc
 */
@WebServlet("/toc")
public class toc extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public toc() {
        super();
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		out.println("<html><body id='tocbody'>");
				
		out.println("<link rel='stylesheet' type='text/css' href='" + request.getContextPath() + 
				"/foticss.css' />");
		
		out.println("<div id='content'>");
		out.println("<div id='chapters'>");
		
		out.println("<form action=toc method=post>");
		
		out.println("<input type=submit name=intro id=chapter value='Introduction'>" +
					"<input type=submit name=ch1 id=chapter value='Chapter 1: Young and Useless'>" + 
					"<input type=submit name=ch2 id=chapter value='Chapter 2: I Must Be Dreaming'>" +
					"<input type=submit name=ch3 id=chapter value='Chapter 3: Whoever He Is'>" +
					"<input type=submit name=ch4 id=chapter value='Chapter 4: Everything's An Illusion'>" +
					"<input type=submit name=ch5 id=chapter value='Chapter 5: Blood Red'>");
		out.println("</form>");


		if (request.getParameter("intro") != null) {
			RequestDispatcher foti = 
					request.getRequestDispatcher("intro.jsp");
				foti.forward(request, response);
			
		}
		
		else if (request.getParameter("ch1") != null) {
			RequestDispatcher foti = 
					request.getRequestDispatcher("Chapter1.jsp");
				foti.forward(request, response);
			
		}
		
		else if (request.getParameter("ch2") != null) {
			RequestDispatcher foti = 
					request.getRequestDispatcher("Chapter2.jsp");
				foti.forward(request, response);
			
		}
		
		else if (request.getParameter("ch3") != null) {
			RequestDispatcher foti = 
					request.getRequestDispatcher("Chapter3.jsp");
				foti.forward(request, response);
			
		}
		
		else if (request.getParameter("ch4") != null) {
			RequestDispatcher foti = 
					request.getRequestDispatcher("Chapter4.jsp");
				foti.forward(request, response);
			
		}
		
		else if (request.getParameter("ch5") != null) {
			RequestDispatcher foti = 
					request.getRequestDispatcher("Chapter5.jsp");
				foti.forward(request, response);
			
		}
		
		out.println("</div>");
		
		out.println("<div id='acknowledgement'>");
		out.println("<p>The developers would like to thank their graphic designers, Dan Augustine and Joshua " +
				"Aguilar of AB Multimedia Arts at the Asia Pacific College, for without them, the project would " +
				"not be as spectacular as the two girls are. <br><br>" +
				"In this work, various developing tools were greatly utilized and studied by the programmers." +
				"Agatha and Izza are truly grateful for the softwares' availability on the internet. <br><br>" +
				"Finally, this project would not be possible if it wasn't an academic requirement" +
				"for Enterprise Java (ENTJAVA) with Mr. Noel Anonas as the subject professor. " +
				"The team could not express enough their emotions toward this program in its entirety.</p>" +
				"</div>");

		out.println("</div>");
	
		out.println("</body></html>");
		
		String vuser = request.getParameter("user");
		String vpass = request.getParameter("pass");
		
		out.println("<h4>Username: " + vuser + "	|	Figment of the Imagination </h4>");	
		
	
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
